<?php
include_once('_PATH.php');
require_once($_CLASSPATH . '/persistence/PersistenceBroker.class.php');

class MoodPersistence extends PersistenceBroker {
	function setMood( $_uid, $_moodType, $_rate , $_moodNote) {
		$query = " INSERT INTO fb_mood (cd_user, cd_moodtype, dt_status, vl_rate, de_note ) VALUES ( $_uid , $_moodType , now() , $_rate , '$_moodNote' ) ";
		$this->broker->execute( $query );
	}
	
	function & getCurrentMood( $_uid ) {
		$query = "SELECT cd_user AS uid, cd_moodtype AS moodType, de_note AS note, dt_status AS statusDate FROM fb_mood WHERE cd_user = 14 ORDER BY dt_status DESC LIMIT 1";

		$rs = $this->broker->executeQuery( $query );
		
		if ( $uidarr = & $this->broker->fecthAssoc( $rs ) ) {
			$mood = new Mood();
			$mood->uid = $uidarr['uid'];
			$mood->type = $uidarr['moodType'];
			$mood->note = $uidarr['note'];
			$mood->statusDate = $uidarr['statusDate'];
		}
		
		$this->broker->disposeResultSet( $rs );
		return $mood;
	}
}
?>